<?php

// Get value of clicked button
$option = $_GET['button'];

// Red wine table
$red = array('Chianti', 'Barolo', 'Pinot Noir');
$white = array('Chardonnay', 'Cava', 'Chablis');

// Combine red and white tables into one multidimensional table
$winetable = array(
      "red" => $red,
      "white" => $white,
);

// Finally depending on the button value, JSON encode our winetable and print it
if ($option == "red") {
  print json_encode($red);
}
else if ($option == "white") {
  print json_encode($white);
}
else {
  print json_encode($winetable);
}

?>